Subscribe Us

Responsive Advertisement

Advertisement

Codeforces Round #761 (Div. 2) B. GCD Problem solution in cpp

 

Codeforces Round #761 (Div. 2)  B. GCD Problem solution in cpp

by ujjal roy



#include<bits/stdc++.h>

using namespace std;

main()

{

    int t,n,i,x,y,z;

    cin>>t;

    int a[]={3,5,7,11,13,17,19,23,29,31,39,41,43,47};

    while(t--)

    {

        cin>>n;

        if(n%2==0)

        {

            cout<<"2 "<<n-3<<" 1"<<endl;

        }

        else

        {

            n--;

            z=1;

            for(i=0;i<14;i++)

            { int g;

                x=a[i];

                y=n-x;

                g=__gcd(x,y);

                if(g==z)

                {

                   cout<<x<<" "<<y<<" "<<z<<endl;

                   break;

                }

            }

        }

    }

    return 0;

}


Post a Comment

0 Comments